]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Don't show the summary if a new item got removed before we had a chance to show it
authorMarina Zhurakhinskaya <marinaz@redhat.com>
Thu, 30 Sep 2010 21:02:16 +0000 (17:02 -0400)
committerMarina Zhurakhinskaya <marinaz@redhat.com>
Tue, 5 Oct 2010 20:14:05 +0000 (16:14 -0400)
It's possible that an item that was added to the summary got removed before
we had a chance to show the summary because the user has interacted with
the notification (e.g. clicked on an application ready notification). We should
not be showing the summary with an unchanged set of items in this case.

However, it is possible that multiple items were added to the summary before
we had a chance to show the summary, and only some of them got removed. In view
of this scenario, we can't just use a boolean flag to indicate if the summary
needs to be shown, but have to maintain an array of new summary items instead.

https://bugzilla.gnome.org/show_bug.cgi?id=630939

js/ui/messageTray.js

index 7bdf2f45fbecc144cca21df858ba21de5a0c5e0b..aa65a155720afab446ff02cd4c1afa42456c3d18 100644 (file)
@@ -917,6 +917,11 @@ MessageTray.prototype = {
             }));
 
         this._summaryItems = [];
+        // We keep a list of new summary items that were added to the summary since the last
+        // time it was shown to the user. We automatically show the summary to the user if there
+        // are items in this list once the notifications are done showing or once an item gets
+        // added to the summary without a notification being shown.
+        this._newSummaryItems = [];
         this._longestSummaryItem = null;
     },
 
@@ -955,7 +960,6 @@ MessageTray.prototype = {
         let summaryItem = new SummaryItem(source, minTitleWidth);
 
         this._summary.insert_actor(summaryItem.actor, 0);
-        this._summaryNeedsToBeShown = true;
 
         let newItemTitleWidth = summaryItem.getTitleNaturalWidth();
         if (newItemTitleWidth > minTitleWidth) {
@@ -967,6 +971,7 @@ MessageTray.prototype = {
         }
 
         this._summaryItems.push(summaryItem);
+        this._newSummaryItems.push(summaryItem);
 
         source.connect('notify', Lang.bind(this, this._onNotify));
 
@@ -1007,6 +1012,10 @@ MessageTray.prototype = {
 
         this._summary.remove_actor(this._summaryItems[index].actor);
 
+        let newSummaryItemsIndex = this._newSummaryItems.indexOf(this._summaryItems[index]);
+        if (newSummaryItemsIndex != -1)
+            this._newSummaryItems.splice(newSummaryItemsIndex, 1);
+
         this._summaryItems.splice(index, 1);
         if (this._longestSummaryItem.source == source) {
 
@@ -1214,7 +1223,7 @@ MessageTray.prototype = {
         let notificationsDone = !notificationsVisible && !notificationsPending;
 
         if (this._summaryState == State.HIDDEN) {
-            if (notificationsDone && this._summaryNeedsToBeShown)
+            if (notificationsDone && this._newSummaryItems.length > 0)
                 this._showSummary(true);
             else if (summarySummoned)
                 this._showSummary(false);
@@ -1438,7 +1447,7 @@ MessageTray.prototype = {
     },
 
     _showSummaryCompleted: function(withTimeout) {
-        this._summaryNeedsToBeShown = false;
+        this._newSummaryItems = [];
 
         if (withTimeout) {
             this._summaryTimeoutId =
@@ -1459,7 +1468,7 @@ MessageTray.prototype = {
                       time: ANIMATION_TIME,
                       transition: 'easeOutQuad'
                     });
-        this._summaryNeedsToBeShown = false;
+        this._newSummaryItems = [];
     },
 
     _showSummaryNotification: function() {